﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.Plumbing
{
	public partial class FormLayPumpBase : System.Windows.Forms.Form
	{
		public FormLayPumpBase(HYPumpData pumpdata)
		{
			this.InitializeComponent();
			base.Icon = Resource.YArchitechIcon;
			this.pumpdata = pumpdata;
		}

		private void InitParameterSetting()
		{
			this.dic = this.userSetting.GetLayPumpBaseSetting();
			this.tboffset.Text = this.userSetting.GetValueFromDic("offset", "0", this.dic);
			try
			{
				this.checkBoxIsDamp.Checked = Convert.ToBoolean(this.userSetting.GetValueFromDic("isDamp", "True", this.dic));
				this.checkIsDown.Checked = Convert.ToBoolean(this.userSetting.GetValueFromDic("isPutDownThePump", "True", this.dic));
			}
			catch (Exception)
			{
			}
		}

		private void UserSettingWrite()
		{
			this.tboffset.Text = StringTools.RemoveZero(this.tboffset.Text.Trim());
			try
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("offset", this.tboffset.Text);
				dictionary.Add("isDamp", this.checkBoxIsDamp.Checked.ToString());
				dictionary.Add("isPutDownThePump", this.checkIsDown.Checked.ToString());
				this.userSetting.WriteLayPumpBaseSetting(dictionary);
			}
			catch (Exception)
			{
			}
		}

		public Dictionary<string, string> GetDampBaseParaFromDBInChinese(HYPumpData pumpdata)
		{
			Dictionary<string, string> dictionary = HYPumpDataManager.ConvertStringToDic(pumpdata.strDampBaseParam);
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			if (pumpdata.strFitRvtName == "1")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair = enumerator.Current;
						string key = keyValuePair.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 1040194900u)
						{
							if (num <= 383896283u)
							{
								if (num != 199048284u)
								{
									if (num == 383896283u)
									{
										if (key == "L2")
										{
											dictionary2.Add("螺栓孔边距(mm)[L2]", keyValuePair.Value);
										}
									}
								}
								else if (key == "B1")
								{
									dictionary2.Add("螺栓孔宽距(mm)[B1]", keyValuePair.Value);
								}
							}
							else if (num != 400673902u)
							{
								if (num == 1040194900u)
								{
									if (key == "PS")
									{
										dictionary2.Add("减震垫规格[PS]", keyValuePair.Value);
									}
								}
							}
							else if (key == "L1")
							{
								dictionary2.Add("螺栓孔长距(mm)[L1]", keyValuePair.Value);
							}
						}
						else if (num <= 3339451269u)
						{
							if (num != 1530585635u)
							{
								if (num == 3339451269u)
								{
									if (key == "B")
									{
										dictionary2.Add("基础宽度(mm)[B]", keyValuePair.Value);
									}
								}
							}
							else if (key == "hf")
							{
								dictionary2.Add("混凝土基础高度(mm)[hf]", keyValuePair.Value);
							}
						}
						else if (num != 3373006507u)
						{
							if (num != 3440116983u)
							{
								if (num == 3775669363u)
								{
									if (key == "d")
									{
										dictionary2.Add("螺栓直径(mm)[d]", keyValuePair.Value);
									}
								}
							}
							else if (key == "H")
							{
								dictionary2.Add("基座高度(mm)[H]", keyValuePair.Value);
							}
						}
						else if (key == "L")
						{
							dictionary2.Add("基础长度(mm)[L]", keyValuePair.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "2")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair2 = enumerator.Current;
						string key = keyValuePair2.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 484561997u)
						{
							if (num <= 249381141u)
							{
								if (num != 199048284u)
								{
									if (num == 249381141u)
									{
										if (key == "B2")
										{
											dictionary2.Add("水泵螺栓孔宽距(mm)[B2]", keyValuePair2.Value);
										}
									}
								}
								else if (key == "B1")
								{
									dictionary2.Add("电机螺栓孔距(mm)[B1]", keyValuePair2.Value);
								}
							}
							else if (num != 367118664u)
							{
								if (num != 383896283u)
								{
									if (num == 484561997u)
									{
										if (key == "L4")
										{
											dictionary2.Add("螺栓孔长距2(mm)[L4]", keyValuePair2.Value);
										}
									}
								}
								else if (key == "L2")
								{
									dictionary2.Add("螺栓孔边距(mm)[L2]", keyValuePair2.Value);
								}
							}
							else if (key == "L3")
							{
								dictionary2.Add("螺栓孔长距1(mm)[L3]", keyValuePair2.Value);
							}
						}
						else if (num <= 3339451269u)
						{
							if (num != 1040194900u)
							{
								if (num != 1530585635u)
								{
									if (num == 3339451269u)
									{
										if (key == "B")
										{
											dictionary2.Add("基础宽度(mm)[B]", keyValuePair2.Value);
										}
									}
								}
								else if (key == "hf")
								{
									dictionary2.Add("混凝土基础高度(mm)[hf]", keyValuePair2.Value);
								}
							}
							else if (key == "PS")
							{
								dictionary2.Add("减震垫规格[PS]", keyValuePair2.Value);
							}
						}
						else if (num != 3373006507u)
						{
							if (num != 3440116983u)
							{
								if (num == 3775669363u)
								{
									if (key == "d")
									{
										dictionary2.Add("螺栓直径(mm)[d]", keyValuePair2.Value);
									}
								}
							}
							else if (key == "H")
							{
								dictionary2.Add("基座高度(mm)[H]", keyValuePair2.Value);
							}
						}
						else if (key == "L")
						{
							dictionary2.Add("基础长度(mm)[L]", keyValuePair2.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "3")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair3 = enumerator.Current;
						string key = keyValuePair3.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 3059570457u)
						{
							if (num <= 1609250850u)
							{
								if (num != 1040194900u)
								{
									if (num == 1609250850u)
									{
										if (key == "Ha")
										{
											dictionary2.Add("基础高度(mm)[Ha]", keyValuePair3.Value);
										}
									}
								}
								else if (key == "PS")
								{
									dictionary2.Add("减震垫规格[PS]", keyValuePair3.Value);
								}
							}
							else if (num != 2403021823u)
							{
								if (num == 3059570457u)
								{
									if (key == "LSK")
									{
										dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair3.Value);
									}
								}
							}
							else if (key == "h2")
							{
								dictionary2.Add("螺栓孔深(mm)[h2]", keyValuePair3.Value);
							}
						}
						else if (num <= 3775669363u)
						{
							if (num != 3339451269u)
							{
								if (num == 3775669363u)
								{
									if (key == "d")
									{
										dictionary2.Add("螺栓直径(mm)[d]", keyValuePair3.Value);
									}
								}
							}
							else if (key == "B")
							{
								dictionary2.Add("基础宽度(mm)[B]", keyValuePair3.Value);
							}
						}
						else if (num != 3876335077u)
						{
							if (num == 3977000791u)
							{
								if (key == "h")
								{
									dictionary2.Add("底座板厚度(mm)[h]", keyValuePair3.Value);
								}
							}
						}
						else if (key == "b")
						{
							dictionary2.Add("螺栓孔距(mm)[b]", keyValuePair3.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "4")
			{
				foreach (KeyValuePair<string, string> keyValuePair4 in dictionary)
				{
					string key = keyValuePair4.Key;
					uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
					if (num <= 2403021823u)
					{
						if (num <= 1609250850u)
						{
							if (num != 1040194900u)
							{
								if (num == 1609250850u)
								{
									if (key == "Ha")
									{
										dictionary2.Add("基础高度(mm)[Ha]", keyValuePair4.Value);
									}
								}
							}
							else if (key == "PS")
							{
								dictionary2.Add("减震垫规格[PS]", keyValuePair4.Value);
							}
						}
						else if (num != 2402036085u)
						{
							if (num == 2403021823u)
							{
								if (key == "h2")
								{
									dictionary2.Add("螺栓孔深(mm)[h2]", keyValuePair4.Value);
								}
							}
						}
						else if (key == "b2")
						{
							dictionary2.Add("基础宽度(mm)[b2]", keyValuePair4.Value);
						}
					}
					else if (num <= 3339451269u)
					{
						if (num != 3059570457u)
						{
							if (num == 3339451269u)
							{
								if (key == "B")
								{
									dictionary2.Add("底座直径(mm)[B]", keyValuePair4.Value);
								}
							}
						}
						else if (key == "LSK")
						{
							dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair4.Value);
						}
					}
					else if (num != 3775669363u)
					{
						if (num != 3876335077u)
						{
							if (num == 3977000791u)
							{
								if (key == "h")
								{
									dictionary2.Add("底座板厚度(mm)[h]", keyValuePair4.Value);
								}
							}
						}
						else if (key == "b")
						{
							dictionary2.Add("螺栓孔距(mm)[b]", keyValuePair4.Value);
						}
					}
					else if (key == "d")
					{
						dictionary2.Add("螺栓直径(mm)[d]", keyValuePair4.Value);
					}
				}
			}
			return dictionary2;
		}

		public Dictionary<string, string> GetBaseParaFromDBInChinese(HYPumpData pumpdata)
		{
			Dictionary<string, string> dictionary = HYPumpDataManager.ConvertStringToDic(pumpdata.strBaseParam);
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			if (pumpdata.strFitRvtName == "1")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair = enumerator.Current;
						string key = keyValuePair.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 1530585635u)
						{
							if (num <= 383896283u)
							{
								if (num != 199048284u)
								{
									if (num == 383896283u)
									{
										if (key == "L2")
										{
											dictionary2.Add("螺栓孔边距(mm)[L2]", keyValuePair.Value);
										}
									}
								}
								else if (key == "B1")
								{
									dictionary2.Add("螺栓孔宽距(mm)[B1]", keyValuePair.Value);
								}
							}
							else if (num != 400673902u)
							{
								if (num != 1463475159u)
								{
									if (num == 1530585635u)
									{
										if (key == "hf")
										{
											dictionary2.Add("地上混凝土高度(mm)[hf]", keyValuePair.Value);
										}
									}
								}
								else if (key == "hz")
								{
									dictionary2.Add("找平层厚度(mm)[hz]", keyValuePair.Value);
								}
							}
							else if (key == "L1")
							{
								dictionary2.Add("螺栓孔长距(mm)[L1]", keyValuePair.Value);
							}
						}
						else if (num <= 3059570457u)
						{
							if (num != 2414576562u)
							{
								if (num == 3059570457u)
								{
									if (key == "LSK")
									{
										dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair.Value);
									}
								}
							}
							else if (key == "H1")
							{
								dictionary2.Add("螺栓孔深(mm)[H1]", keyValuePair.Value);
							}
						}
						else if (num != 3339451269u)
						{
							if (num != 3373006507u)
							{
								if (num == 3440116983u)
								{
									if (key == "H")
									{
										dictionary2.Add("基础高度(mm)[H]", keyValuePair.Value);
									}
								}
							}
							else if (key == "L")
							{
								dictionary2.Add("基础长度(mm)[L]", keyValuePair.Value);
							}
						}
						else if (key == "B")
						{
							dictionary2.Add("基础宽度(mm)[B]", keyValuePair.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "2")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair2 = enumerator.Current;
						string key = keyValuePair2.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 1463475159u)
						{
							if (num <= 367118664u)
							{
								if (num != 199048284u)
								{
									if (num != 249381141u)
									{
										if (num == 367118664u)
										{
											if (key == "L3")
											{
												dictionary2.Add("螺栓孔长距(mm)[L3]", keyValuePair2.Value);
											}
										}
									}
									else if (key == "B2")
									{
										dictionary2.Add("螺栓孔宽距(mm)[B2]", keyValuePair2.Value);
									}
								}
								else if (key == "B1")
								{
									dictionary2.Add("电机基础宽度(mm)[B1]", keyValuePair2.Value);
								}
							}
							else if (num != 383896283u)
							{
								if (num != 484561997u)
								{
									if (num == 1463475159u)
									{
										if (key == "hz")
										{
											dictionary2.Add("找平层厚度(mm)[hz]", keyValuePair2.Value);
										}
									}
								}
								else if (key == "L4")
								{
									dictionary2.Add("螺栓孔长距2(mm)[L4]", keyValuePair2.Value);
								}
							}
							else if (key == "L2")
							{
								dictionary2.Add("螺栓孔边距(mm)[L2]", keyValuePair2.Value);
							}
						}
						else if (num <= 3059570457u)
						{
							if (num != 1530585635u)
							{
								if (num != 2414576562u)
								{
									if (num == 3059570457u)
									{
										if (key == "LSK")
										{
											dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair2.Value);
										}
									}
								}
								else if (key == "H1")
								{
									dictionary2.Add("螺栓孔深(mm)[H1]", keyValuePair2.Value);
								}
							}
							else if (key == "hf")
							{
								dictionary2.Add("地面以上高度(mm)[hf]", keyValuePair2.Value);
							}
						}
						else if (num <= 3373006507u)
						{
							if (num != 3339451269u)
							{
								if (num == 3373006507u)
								{
									if (key == "L")
									{
										dictionary2.Add("基础长度(mm)[L]", keyValuePair2.Value);
									}
								}
							}
							else if (key == "B")
							{
								dictionary2.Add("基础宽度(mm)[B]", keyValuePair2.Value);
							}
						}
						else if (num != 3440116983u)
						{
							if (num == 3775669363u)
							{
								if (key == "d")
								{
									dictionary2.Add("螺栓直径(mm)[d]", keyValuePair2.Value);
								}
							}
						}
						else if (key == "H")
						{
							dictionary2.Add("基础高度(mm)[H]", keyValuePair2.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "3")
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair3 = enumerator.Current;
						string key = keyValuePair3.Key;
						uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
						if (num <= 3059570457u)
						{
							if (num <= 2402036085u)
							{
								if (num != 1609250850u)
								{
									if (num == 2402036085u)
									{
										if (key == "b2")
										{
											dictionary2.Add("基础宽度(mm)[b2]", keyValuePair3.Value);
										}
									}
								}
								else if (key == "Ha")
								{
									dictionary2.Add("基础高度(mm)[Ha]", keyValuePair3.Value);
								}
							}
							else if (num != 2403021823u)
							{
								if (num == 3059570457u)
								{
									if (key == "LSK")
									{
										dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair3.Value);
									}
								}
							}
							else if (key == "h2")
							{
								dictionary2.Add("螺栓孔深(mm)[h2]", keyValuePair3.Value);
							}
						}
						else if (num <= 3775669363u)
						{
							if (num != 3339451269u)
							{
								if (num == 3775669363u)
								{
									if (key == "d")
									{
										dictionary2.Add("螺栓直径(mm)[d]", keyValuePair3.Value);
									}
								}
							}
							else if (key == "B")
							{
								dictionary2.Add("底座宽度(mm)[B]", keyValuePair3.Value);
							}
						}
						else if (num != 3876335077u)
						{
							if (num == 3977000791u)
							{
								if (key == "h")
								{
									dictionary2.Add("底座板厚度(mm)[h]", keyValuePair3.Value);
								}
							}
						}
						else if (key == "b")
						{
							dictionary2.Add("螺栓孔距(mm)[b]", keyValuePair3.Value);
						}
					}
					return dictionary2;
				}
			}
			if (pumpdata.strFitRvtName == "4")
			{
				foreach (KeyValuePair<string, string> keyValuePair4 in dictionary)
				{
					string key = keyValuePair4.Key;
					uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(key);
					if (num <= 3059570457u)
					{
						if (num <= 2402036085u)
						{
							if (num != 1609250850u)
							{
								if (num == 2402036085u)
								{
									if (key == "b2")
									{
										dictionary2.Add("基础宽度(mm)[b2]", keyValuePair4.Value);
									}
								}
							}
							else if (key == "Ha")
							{
								dictionary2.Add("基础高度(mm)[Ha]", keyValuePair4.Value);
							}
						}
						else if (num != 2403021823u)
						{
							if (num == 3059570457u)
							{
								if (key == "LSK")
								{
									dictionary2.Add("螺栓孔边长(mm)[LSK]", keyValuePair4.Value);
								}
							}
						}
						else if (key == "h2")
						{
							dictionary2.Add("螺栓孔深(mm)[h2]", keyValuePair4.Value);
						}
					}
					else if (num <= 3775669363u)
					{
						if (num != 3339451269u)
						{
							if (num == 3775669363u)
							{
								if (key == "d")
								{
									dictionary2.Add("螺栓直径(mm)[d]", keyValuePair4.Value);
								}
							}
						}
						else if (key == "B")
						{
							dictionary2.Add("底座直径(mm)[B]", keyValuePair4.Value);
						}
					}
					else if (num != 3876335077u)
					{
						if (num == 3977000791u)
						{
							if (key == "h")
							{
								dictionary2.Add("底座板厚度(mm)[h]", keyValuePair4.Value);
							}
						}
					}
					else if (key == "b")
					{
						dictionary2.Add("螺栓孔距(mm)[b]", keyValuePair4.Value);
					}
				}
			}
			return dictionary2;
		}

		public void InitDataGridViewPara()
		{
			this.dataGridViewPara.Rows.Clear();
			if (this.checkBoxIsDamp.Checked)
			{
				this.dicPara = this.GetDampBaseParaFromDBInChinese(this.pumpdata);
			}
			else
			{
				this.dicPara = this.GetBaseParaFromDBInChinese(this.pumpdata);
			}
			foreach (KeyValuePair<string, string> keyValuePair in this.dicPara)
			{
				this.dataGridViewPara.Rows.Add(new object[]
				{
					keyValuePair.Key,
					keyValuePair.Value
				});
			}
		}

		public void InitPictureBox()
		{
			if (this.checkBoxIsDamp.Checked)
			{
				if (File.Exists(this.pumpbase.dampimage))
				{
					this.pictureBox.Image = new Bitmap(this.pumpbase.dampimage);
					return;
				}
				this.pictureBox.Image = null;
				return;
			}
			else
			{
				if (File.Exists(this.pumpbase.image))
				{
					this.pictureBox.Image = new Bitmap(this.pumpbase.image);
					return;
				}
				this.pictureBox.Image = null;
				return;
			}
		}

		public void RefreshThePumpdata(HYPumpData pumpdata)
		{
			if (!HYPumpDataManager.GetSpecPumpData(ref pumpdata))
			{
				YJKMessageBox.Information("水泵类型获取失败，请重新选择符合盈建科族规格的水泵");
			}
			this.pumpbase = HYPumpDataManager.GetPumpBaseDataById(pumpdata.strFitRvtName, "PumpBase");
			this.textBoxSpec.Text = pumpdata.StrSpecification;
			this.InitDataGridViewPara();
			this.InitPictureBox();
		}

		private void FormLayPumpBase_Load(object sender, EventArgs e)
		{
			this.InitParameterSetting();
			this.RefreshThePumpdata(this.pumpdata);
		}

		private void btnChoosePump_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Abort;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.tboffset.Text != "")
			{
				this.offset = double.Parse(this.tboffset.Text);
				if (this.checkBoxIsDamp.Checked)
				{
					this.family = this.pumpbase.dampfamilyname;
					this.isDamp = true;
				}
				else
				{
					this.family = this.pumpbase.familyname;
					this.isDamp = false;
				}
				if (this.checkIsDown.Checked)
				{
					this.isPutDownThePump = true;
				}
				else
				{
					this.isPutDownThePump = false;
				}
				this.UserSettingWrite();
				base.DialogResult = DialogResult.OK;
			}
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void checkBoxIsDamp_CheckedChanged(object sender, EventArgs e)
		{
			this.InitDataGridViewPara();
			this.InitPictureBox();
		}

		private void checkIsDown_CheckedChanged(object sender, EventArgs e)
		{
			if (this.checkIsDown.Checked)
			{
				this.tboffset.Enabled = false;
				return;
			}
			this.tboffset.Enabled = true;
		}

		private HYPumpData pumpdata = new HYPumpData();

		private Dictionary<string, string> dicPara = new Dictionary<string, string>();

		public HYPumpBase pumpbase = new HYPumpBase();

		public string family = "";

		public bool isDamp = true;

		public double offset;

		public bool isPutDownThePump;

		private Dictionary<string, string> dic;

		private HVACUserSetting userSetting = new HVACUserSetting();
	}
}
